package com.zhongxi.guoyuan.OffLineShop.UI;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ProgressBar;

import com.zhongxi.guoyuan.R;

import io.reactivex.disposables.Disposable;

/**
 * Created by Administrator on 2018/1/18.
 */

public class OffLineBaseActivity extends AppCompatActivity {

    protected Disposable mDisposable;
    protected int page = 1;
    private ProgressBar mProgressBar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        initActionBar();
        initView();
        initNetWork();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();
        initListener();
    }

    protected void init() {

    }

    protected void initActionBar() {

    }

    protected void initView() {

    }

    protected void initNetWork() {

    }

    protected void initListener() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unsubscribe();
    }

    protected void unsubscribe() {
        if (mDisposable != null && !mDisposable.isDisposed()) {
            mDisposable.dispose();
        }
    }

    protected void showProgressDialog() {
        if (mProgressBar == null) {
            mProgressBar = new ProgressBar(this);
        }
        mProgressBar.setVisibility(View.VISIBLE);
//        mProgressDialog.setMessage("加载中....");
//        mProgressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressbarstyle_large));
    }

    protected void dismessProgressDialog() {
        if (mProgressBar != null && mProgressBar.isShown()) {
            mProgressBar.setVisibility(View.GONE);
        }
    }

}
